
	******************************************************************
	**
	**
	**		NAME:		GUY GROSSMAN, YOTAM MARGALIT, TAMAR MITTS
	**		DATE: 		December 15, 2021
	**		PROJECT: 	Israel Hayom
	**		DETAILS: 	This code generates Table 1
	**		Version: 	Stata MP 16
	**
	******************************************************************

			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**

clear
version 16
set scheme plotplain
set more off

capture cd "~/dropbox/Israeli Newspapers Study/JOP_REPLICATION/Dataverse submission"

* bring in dataset

use "Data/yeshuvlong_final.dta"

* additional cleaning

replace israelhayom_percent_e=0 if israelhayom_percent_e==. & year<2007
replace israelhayom_percent=0 if israelhayom_percent==. & year<2007
replace israelhayom_percent_cumulative=0 if israelhayom_percent_cumulativ==. & year<2007

drop if area_num >25

keep if BIG_rightbloc!=.
tabulate year, gen(YEAR)

* gen a running number for election years
egen yr = group(year)
move yr year

gen lpop= log(potential)
gen ltd = log(travel_dist)

* generate turnout var
gen turnout = voters/potential
replace turnout = 1 if turnout>1
replace turnout = turnout*100
tab year, summ(turnout)

* population share by age group
gen pop_share1829 = pop_M_18_29 / pop_total
gen pop_share3049 = pop_M_30_49 /pop_total
gen pop_share5065 = pop_M_50_65 /pop_total
gen pop_share66 = pop_M_66 / pop_total
gen pop_adult = pop_M_18_29 + pop_M_30_49 + pop_M_50_65 + pop_M_66

 foreach var in pop_share1829 pop_share3049 pop_share5065 pop_share66{
	replace `var'=0 if `var'<0
 }

tabstat ltd lpop age_median_08 matriccert_pcnt_08 europe_pcnt_08 asia_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66, by(yr)

corr ltd lpop age_median_08 potential matriccert_pcnt_08 europe_pcnt_08  asia_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66 if yr==4

* generate otherpapers var for attentativeness measure
egen otherpapers=rowtotal(maariv_percent haaretz_percent globes_percent marker_percent calcalist_percent israelpost_percent makorrishon_percent) if year==2006
	bysort area_num: egen otherpapers2006=max(otherpapers)
	drop otherpapers

* rename parties

ren BIG_rightbloc BRB
ren israelhayom_percent_electionyear IHE

* rename instruments
ren secular_max IVsm
ren secular_max07H1 IVsm07H1
ren sec_max06h2_07H1 IVsm06h2_07H1

tabstat IVsm IVsm07H1 IVsm06h2_07H1,  by(year)
corr IVsm IVsm07H1 IVsm06h2_07H1
drop IVsm

bysort area_num: egen IVsm=mean(IVsm07H1)
bysort area_num: egen IVsmp=mean(IVsm06h2_07H1)
tabstat IVsm IVsmp, by(year)
drop IVsm07H1 IVsm06h2_07H1

* generate variable of base level of support for right bloc and Likud
foreach var in BRB {
	bysort uniqueid: egen `var'0 = mean(`var') if yr<5
	bysort uniqueid: egen `var'Pre = mean(`var'0)
	drop `var'0
	}

* use LERI score to calculate mean ideology support at baseline
table year uniqueid if uniqueid<6, c(mean leri_score )
foreach var in leri_AVscore leri_score{
	bysort uniqueid: egen `var'0 = mean(`var') if yr<5
	bysort uniqueid: egen `var'Pre = mean(`var'0)
	drop `var'0
	}

gl covs ltd lpop religion_pcnt matriccert_pcnt_08 europe_pcnt_08 asia_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66  
su $covs	

xtset uniqueid yr
sort uniqueid yr
estimates drop _all

*******************************************
* Instrument exogeneity
********************************************

forvalues i = 1(1)4 {
			bootstrap, reps(250) seed(725`i') cl(area_num) idcl(new_area_num) group(uniqueid) force : reg BRB IVsm if yr==`i' [aw=potential], cl(area_num)
			estadd local covs "No"
			estadd local boot "Yes"
			capture est sto BRBa`i'

			bootstrap, reps(250) seed(725`i') cl(area_num) idcl(new_area_num) group(uniqueid) force : reg BRB IVsm $covs if yr==`i' [aw=potential], cl(area_num)
			estadd local covs "Yes"
			estadd local boot "Yes"
			capture est sto BRBb`i'
			}


# delimit ;
esttab BRBa1 BRBb1 BRBa2 BRBb2 BRBa3 BRBb3 BRBa4 BRBb4
		using "Tables/Table_1.tex", replace
		keep(IVsm _cons) cells(b(fmt(%5.3f) star) se(fmt(%5.3f) par))
		starlevels(* .10 ** .05 *** .01)
		mgroups("\textbf{1996}" "\textbf{1999}" "\textbf{2003}" "\textbf{2006}", pattern(1 0 1 0 1 0 1 0 1 0)
		span prefix(\multicolumn{@span}{c}{) suffix(}) erepeat(\cmidrule(lr){@span})) nomtitles
		varlabels(IVsm "Yediot readership 2007" _cons "Constant")
		stats(covs r2 N, labels("Covariates" "R2" "N")
		fmt(0 2 0)) collabels(none) label booktabs nonotes
		;
		#delimit cr
